package com.lin.healthmanagement.controller.exception;

import com.lin.healthmanagement.controller.code.Code;
import com.lin.healthmanagement.controller.code.Message;
import com.lin.healthmanagement.controller.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ProjectExceptionAdvice {
    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException e){
        return new Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(SystemException.class)
    public Result doSystemException(SystemException e){
        return new  Result(e.getCode(),e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result doException(Exception e){
        return new Result(Code.UN_KNOWN_EXCEPTION,e.getMessage());
    }

}
